//
//  main.m
//  5-11复习
//
//  Created by 钟纪旺 on 16/5/11.
//  Copyright © 2016年 zjw. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        NSString *path =@"/Users/zhongjiwang/Desktop/cbv.vcf";
        NSError *err;
        NSString *vcf = [[NSString alloc]initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
        if (err !=0) {
            NSLog(@"%@",err);
        }
        NSArray *arr = [vcf componentsSeparatedByString:@"\n"];
        NSMutableArray *res =[NSMutableArray new];
        NSMutableDictionary *diti;
        for (NSString *lien in arr) {
            if ([lien hasPrefix:@"BEGIN"]) {
                NSLog(@"开始");
                diti = [NSMutableDictionary new];
            }if ([lien hasPrefix:@"END"]) {
                NSLog(@"结束");
            [res addObject:diti];
            }if ([lien hasPrefix:@"TEL"]) {
                NSArray *tels = [lien
            componentsSeparatedByString:@":"];
                NSString *last = tels.lastObject;
                diti [@"tel"]=last;
                NSLog(@"%@",last);
                
            }if ([lien hasPrefix:@"FN"]) {
                NSArray *names =[lien componentsSeparatedByString:@":"];                NSString *name =names.lastObject;
                diti[@"name"]=name;
                
                
                
                
                
                NSLog(@"%@",names);
                
                
                
                
            }
        }
        
        NSLog(@"%@",res);
        
        
        
        
        
    }
    return 0;
}
